from django.db import models

from userapp.model_one.base_model import BaseModel


# Create your models here.

# 一对一的关联关系 例如用户的身份证号码
class IdCard(BaseModel):
    number = models.CharField(max_length=18, null=True, unique=True, blank=True, verbose_name="省份证号码")
    adders = models.CharField(max_length=40, null=True, blank=True, verbose_name="发证地点")

    class Meta:
        db_table = 'id_card'
        verbose_name = '身份证表'
        verbose_name_plural = verbose_name
        ordering = ['id']

    def __str__(self):
        return f'省份证号码:{self.number}, 发证地址:{self.adders}'


# 多对多的关联属性
class RoleModel(BaseModel):
    name = models.CharField(max_length=30, unique=True, null=True, blank=True, verbose_name='权限表')

    class Meta:
        db_table = 't_role'
        verbose_name = '权限表'
        verbose_name_plural = verbose_name
        ordering = ['id']

    def __str__(self):
        return f"权限:{self.name}"
